package com.emmmya.ocs.modules.system.businessSetting.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.emmmya.harinCheck.annotation.Check;
import com.emmmya.ocs.common.base.BaseEntity;
import com.emmmya.ocs.common.converter.JpaConverterListJson;
import com.emmmya.ocs.config.mybatis.handler.StringListJSONTypeHandler;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;

/**
 * 创建人：咕噜肉IT小店-黑医
 * 创建时间 2022年09月23日 08:17:05
 * 描述：业务邮箱配置基础类，根据不用模块，区分邮箱接收人，自定义模板
 */
@Data
@Entity
@Table(name="h_business_mail_setting")
@TableName("h_business_mail_setting")
public class BusinessMailSetting extends BaseEntity {

    @Check(name = "邮件标题")
    @Column(name = "title",columnDefinition = "varchar(300)")
    @TableField("title")
    private String title;

    @Check(name = "邮件内容")
    @Column(name = "content",columnDefinition = "varchar(3000)")
    @TableField("content")
    private String content;

    @Check(name = "邮件默认接收人")
    @Column(name = "defualt_recipient",columnDefinition = "JSON")
    @TableField(value = "defualt_recipiener", typeHandler = StringListJSONTypeHandler.class)
    @Convert(converter = JpaConverterListJson.class)
    private List<String> defualtRecipiener;

    @Check(name="异常邮件接收人")
    @Column(name = "abnormal_recipient",columnDefinition = "JSON")
    @TableField(value = "abnormal_recipiener", typeHandler = StringListJSONTypeHandler.class)
    @Convert(converter = JpaConverterListJson.class)
    private List<String> abnormalRecipiener;

    @Check(name="配置key")
    @Column(name = "`key`",columnDefinition = "varchar(30)" ,unique = true)
    @TableField(value = "key")
    private String key;

    public BusinessMailSetting(){

    }
    public BusinessMailSetting(String key) {
        this.key = key;
    }
}
